﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace EuroManager.Domain.Simulator.Tactics
{
    public class Tactics442 : ITeamTactics
    {
        private PlayerTactics[] tactics;

        public Tactics442()
        {
            tactics = new PlayerTactics[]
            {
                CreateGoalkeeperTactics(),

                CreateLeftDefenderTactics(),
                CreateCentralLeftDefenderTactics(),
                CreateCentralRightDefenderTactics(),
                CreateRightDefenderTactics(),
                
                CreateLeftMidfielderTactics(),
                CreateCentralLeftMidfielderTactics(),
                CreateCentralRightMidfielderTactics(),
                CreateRightMidfielderTactics(),
                
                CreateLeftForwardTactics(),
                CreateRightForwardTactics()
            };
        }

        public PlayerTactics GetPlayerTactics(int index)
        {
            return tactics[index];
        }

        private PlayerTactics CreateGoalkeeperTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.01f, 0.50f);
            
            pt.Assign(0, 0, 0.00f, 0.45f);
            pt.Assign(0, 1, 0.00f, 0.48f);
            pt.Assign(0, 2, 0.00f, 0.52f);
            pt.Assign(0, 3, 0.00f, 0.55f);
            
            pt.Assign(1, 0, 0.01f, 0.44f);
            pt.Assign(1, 1, 0.01f, 0.48f);
            pt.Assign(1, 2, 0.01f, 0.52f);
            pt.Assign(1, 3, 0.01f, 0.56f);
            
            pt.Assign(2, 0, 0.02f, 0.40f);
            pt.Assign(2, 1, 0.02f, 0.46f);
            pt.Assign(2, 2, 0.02f, 0.54f);
            pt.Assign(2, 3, 0.02f, 0.50f);

            pt.Assign(3, 0, 0.04f, 0.40f);
            pt.Assign(3, 1, 0.04f, 0.46f);
            pt.Assign(3, 2, 0.04f, 0.54f);
            pt.Assign(3, 3, 0.04f, 0.50f);

            pt.Assign(4, 0, 0.05f, 0.40f);
            pt.Assign(4, 1, 0.05f, 0.46f);
            pt.Assign(4, 2, 0.05f, 0.54f);
            pt.Assign(4, 3, 0.05f, 0.50f);

            pt.Assign(5, 0, 0.06f, 0.40f);
            pt.Assign(5, 1, 0.06f, 0.46f);
            pt.Assign(5, 2, 0.06f, 0.54f);
            pt.Assign(5, 3, 0.06f, 0.50f);

            return pt;
        }

        private PlayerTactics CreateLeftDefenderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.18f, 0.20f);

            pt.Assign(0, 0, 0.04f, 0.15f);
            pt.Assign(0, 1, 0.04f, 0.25f);
            pt.Assign(0, 2, 0.04f, 0.32f);
            pt.Assign(0, 3, 0.04f, 0.36f);

            pt.Assign(1, 0, 0.16f, 0.18f);
            pt.Assign(1, 1, 0.16f, 0.28f);
            pt.Assign(1, 2, 0.16f, 0.33f);
            pt.Assign(1, 3, 0.16f, 0.38f);

            pt.Assign(2, 0, 0.28f, 0.20f);
            pt.Assign(2, 1, 0.28f, 0.30f);
            pt.Assign(2, 2, 0.28f, 0.35f);
            pt.Assign(2, 3, 0.28f, 0.40f);

            pt.Assign(3, 0, 0.40f, 0.15f);
            pt.Assign(3, 1, 0.40f, 0.20f);
            pt.Assign(3, 2, 0.40f, 0.28f);
            pt.Assign(3, 3, 0.40f, 0.35f);

            pt.Assign(4, 0, 0.54f, 0.10f);
            pt.Assign(4, 1, 0.54f, 0.17f);
            pt.Assign(4, 2, 0.54f, 0.24f);
            pt.Assign(4, 3, 0.54f, 0.30f);

            pt.Assign(5, 0, 0.68f, 0.05f);
            pt.Assign(5, 1, 0.68f, 0.13f);
            pt.Assign(5, 2, 0.68f, 0.20f);
            pt.Assign(5, 3, 0.68f, 0.27f);

            return pt;
        }

        private PlayerTactics CreateCentralLeftDefenderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.17f, 0.40f);

            pt.Assign(0, 0, 0.05f, 0.32f);
            pt.Assign(0, 1, 0.05f, 0.40f);
            pt.Assign(0, 2, 0.05f, 0.46f);
            pt.Assign(0, 3, 0.05f, 0.50f);

            pt.Assign(1, 0, 0.16f, 0.31f);
            pt.Assign(1, 1, 0.16f, 0.39f);
            pt.Assign(1, 2, 0.16f, 0.45f);
            pt.Assign(1, 3, 0.16f, 0.49f);

            pt.Assign(2, 0, 0.26f, 0.30f);
            pt.Assign(2, 1, 0.26f, 0.38f);
            pt.Assign(2, 2, 0.26f, 0.44f);
            pt.Assign(2, 3, 0.26f, 0.48f);

            pt.Assign(3, 0, 0.38f, 0.30f);
            pt.Assign(3, 1, 0.38f, 0.38f);
            pt.Assign(3, 2, 0.38f, 0.44f);
            pt.Assign(3, 3, 0.38f, 0.48f);

            pt.Assign(4, 0, 0.50f, 0.30f);
            pt.Assign(4, 1, 0.50f, 0.38f);
            pt.Assign(4, 2, 0.50f, 0.44f);
            pt.Assign(4, 3, 0.50f, 0.48f);

            pt.Assign(5, 0, 0.58f, 0.30f);
            pt.Assign(5, 1, 0.58f, 0.38f);
            pt.Assign(5, 2, 0.58f, 0.44f);
            pt.Assign(5, 3, 0.58f, 0.48f);

            return pt;
        }

        private PlayerTactics CreateCentralRightDefenderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.17f, 0.60f);

            pt.Assign(0, 0, 0.05f, 0.50f);
            pt.Assign(0, 1, 0.05f, 0.54f);
            pt.Assign(0, 2, 0.05f, 0.60f);
            pt.Assign(0, 3, 0.05f, 0.68f);

            pt.Assign(1, 0, 0.16f, 0.51f);
            pt.Assign(1, 1, 0.16f, 0.55f);
            pt.Assign(1, 2, 0.16f, 0.61f);
            pt.Assign(1, 3, 0.16f, 0.69f);

            pt.Assign(2, 0, 0.26f, 0.52f);
            pt.Assign(2, 1, 0.26f, 0.56f);
            pt.Assign(2, 2, 0.26f, 0.62f);
            pt.Assign(2, 3, 0.26f, 0.70f);

            pt.Assign(3, 0, 0.38f, 0.52f);
            pt.Assign(3, 1, 0.38f, 0.56f);
            pt.Assign(3, 2, 0.38f, 0.62f);
            pt.Assign(3, 3, 0.38f, 0.70f);

            pt.Assign(4, 0, 0.50f, 0.52f);
            pt.Assign(4, 1, 0.50f, 0.56f);
            pt.Assign(4, 2, 0.50f, 0.62f);
            pt.Assign(4, 3, 0.50f, 0.70f);

            pt.Assign(5, 0, 0.58f, 0.52f);
            pt.Assign(5, 1, 0.58f, 0.56f);
            pt.Assign(5, 2, 0.58f, 0.62f);
            pt.Assign(5, 3, 0.58f, 0.70f);

            return pt;
        }

        private PlayerTactics CreateRightDefenderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.18f, 0.80f);

            pt.Assign(0, 0, 0.04f, 0.64f);
            pt.Assign(0, 1, 0.04f, 0.68f);
            pt.Assign(0, 2, 0.04f, 0.75f);
            pt.Assign(0, 3, 0.04f, 0.85f);

            pt.Assign(1, 0, 0.16f, 0.62f);
            pt.Assign(1, 1, 0.16f, 0.67f);
            pt.Assign(1, 2, 0.16f, 0.72f);
            pt.Assign(1, 3, 0.16f, 0.82f);

            pt.Assign(2, 0, 0.28f, 0.60f);
            pt.Assign(2, 1, 0.28f, 0.65f);
            pt.Assign(2, 2, 0.28f, 0.70f);
            pt.Assign(2, 3, 0.28f, 0.80f);

            pt.Assign(3, 0, 0.40f, 0.65f);
            pt.Assign(3, 1, 0.40f, 0.72f);
            pt.Assign(3, 2, 0.40f, 0.80f);
            pt.Assign(3, 3, 0.40f, 0.85f);

            pt.Assign(4, 0, 0.54f, 0.70f);
            pt.Assign(4, 1, 0.54f, 0.76f);
            pt.Assign(4, 2, 0.54f, 0.83f);
            pt.Assign(4, 3, 0.54f, 0.90f);

            pt.Assign(5, 0, 0.68f, 0.73f);
            pt.Assign(5, 1, 0.68f, 0.80f);
            pt.Assign(5, 2, 0.68f, 0.87f);
            pt.Assign(5, 3, 0.68f, 0.95f);

            return pt;
        }

        private PlayerTactics CreateLeftMidfielderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.45f, 0.20f);

            pt.Assign(0, 0, 0.17f, 0.15f);
            pt.Assign(0, 1, 0.17f, 0.25f);
            pt.Assign(0, 2, 0.17f, 0.32f);
            pt.Assign(0, 3, 0.17f, 0.36f);

            pt.Assign(1, 0, 0.35f, 0.18f);
            pt.Assign(1, 1, 0.35f, 0.28f);
            pt.Assign(1, 2, 0.35f, 0.33f);
            pt.Assign(1, 3, 0.35f, 0.38f);

            pt.Assign(2, 0, 0.50f, 0.20f);
            pt.Assign(2, 1, 0.50f, 0.30f);
            pt.Assign(2, 2, 0.50f, 0.35f);
            pt.Assign(2, 3, 0.50f, 0.40f);

            pt.Assign(3, 0, 0.65f, 0.15f);
            pt.Assign(3, 1, 0.65f, 0.20f);
            pt.Assign(3, 2, 0.65f, 0.28f);
            pt.Assign(3, 3, 0.65f, 0.35f);

            pt.Assign(4, 0, 0.80f, 0.10f);
            pt.Assign(4, 1, 0.80f, 0.17f);
            pt.Assign(4, 2, 0.80f, 0.24f);
            pt.Assign(4, 3, 0.80f, 0.30f);

            pt.Assign(5, 0, 0.88f, 0.05f);
            pt.Assign(5, 1, 0.88f, 0.13f);
            pt.Assign(5, 2, 0.88f, 0.20f);
            pt.Assign(5, 3, 0.88f, 0.27f);

            return pt;
        }

        private PlayerTactics CreateCentralLeftMidfielderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.35f, 0.40f);

            pt.Assign(0, 0, 0.10f, 0.32f);
            pt.Assign(0, 1, 0.10f, 0.40f);
            pt.Assign(0, 2, 0.10f, 0.46f);
            pt.Assign(0, 3, 0.10f, 0.50f);

            pt.Assign(1, 0, 0.20f, 0.30f);
            pt.Assign(1, 1, 0.20f, 0.38f);
            pt.Assign(1, 2, 0.20f, 0.44f);
            pt.Assign(1, 3, 0.20f, 0.48f);

            pt.Assign(2, 0, 0.36f, 0.28f);
            pt.Assign(2, 1, 0.36f, 0.36f);
            pt.Assign(2, 2, 0.36f, 0.42f);
            pt.Assign(2, 3, 0.36f, 0.46f);

            pt.Assign(3, 0, 0.52f, 0.28f);
            pt.Assign(3, 1, 0.52f, 0.36f);
            pt.Assign(3, 2, 0.52f, 0.42f);
            pt.Assign(3, 3, 0.52f, 0.46f);

            pt.Assign(4, 0, 0.67f, 0.28f);
            pt.Assign(4, 1, 0.67f, 0.36f);
            pt.Assign(4, 2, 0.67f, 0.42f);
            pt.Assign(4, 3, 0.67f, 0.46f);

            pt.Assign(5, 0, 0.84f, 0.28f);
            pt.Assign(5, 1, 0.84f, 0.36f);
            pt.Assign(5, 2, 0.84f, 0.42f);
            pt.Assign(5, 3, 0.84f, 0.46f);

            return pt;
        }

        private PlayerTactics CreateCentralRightMidfielderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.35f, 0.60f);

            pt.Assign(0, 0, 0.10f, 0.50f);
            pt.Assign(0, 1, 0.10f, 0.54f);
            pt.Assign(0, 2, 0.10f, 0.60f);
            pt.Assign(0, 3, 0.10f, 0.68f);

            pt.Assign(1, 0, 0.20f, 0.52f);
            pt.Assign(1, 1, 0.20f, 0.56f);
            pt.Assign(1, 2, 0.20f, 0.62f);
            pt.Assign(1, 3, 0.20f, 0.70f);

            pt.Assign(2, 0, 0.36f, 0.54f);
            pt.Assign(2, 1, 0.36f, 0.58f);
            pt.Assign(2, 2, 0.36f, 0.64f);
            pt.Assign(2, 3, 0.36f, 0.72f);

            pt.Assign(3, 0, 0.52f, 0.54f);
            pt.Assign(3, 1, 0.52f, 0.58f);
            pt.Assign(3, 2, 0.52f, 0.64f);
            pt.Assign(3, 3, 0.52f, 0.72f);

            pt.Assign(4, 0, 0.67f, 0.54f);
            pt.Assign(4, 1, 0.67f, 0.58f);
            pt.Assign(4, 2, 0.67f, 0.64f);
            pt.Assign(4, 3, 0.67f, 0.72f);

            pt.Assign(5, 0, 0.84f, 0.54f);
            pt.Assign(5, 1, 0.84f, 0.58f);
            pt.Assign(5, 2, 0.84f, 0.64f);
            pt.Assign(5, 3, 0.84f, 0.72f);

            return pt;
        }

        private PlayerTactics CreateRightMidfielderTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.45f, 0.80f);

            pt.Assign(0, 0, 0.17f, 0.64f);
            pt.Assign(0, 1, 0.17f, 0.68f);
            pt.Assign(0, 2, 0.17f, 0.75f);
            pt.Assign(0, 3, 0.17f, 0.85f);

            pt.Assign(1, 0, 0.35f, 0.62f);
            pt.Assign(1, 1, 0.35f, 0.67f);
            pt.Assign(1, 2, 0.35f, 0.72f);
            pt.Assign(1, 3, 0.35f, 0.82f);

            pt.Assign(2, 0, 0.50f, 0.60f);
            pt.Assign(2, 1, 0.50f, 0.65f);
            pt.Assign(2, 2, 0.50f, 0.70f);
            pt.Assign(2, 3, 0.50f, 0.80f);

            pt.Assign(3, 0, 0.65f, 0.65f);
            pt.Assign(3, 1, 0.65f, 0.72f);
            pt.Assign(3, 2, 0.65f, 0.80f);
            pt.Assign(3, 3, 0.65f, 0.85f);

            pt.Assign(4, 0, 0.80f, 0.70f);
            pt.Assign(4, 1, 0.80f, 0.76f);
            pt.Assign(4, 2, 0.80f, 0.83f);
            pt.Assign(4, 3, 0.80f, 0.90f);

            pt.Assign(5, 0, 0.88f, 0.73f);
            pt.Assign(5, 1, 0.88f, 0.80f);
            pt.Assign(5, 2, 0.88f, 0.87f);
            pt.Assign(5, 3, 0.88f, 0.95f);

            return pt;
        }

        private PlayerTactics CreateLeftForwardTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.45f, 0.44f);

            pt.Assign(0, 0, 0.30f, 0.32f);
            pt.Assign(0, 1, 0.30f, 0.40f);
            pt.Assign(0, 2, 0.30f, 0.46f);
            pt.Assign(0, 3, 0.30f, 0.50f);

            pt.Assign(1, 0, 0.45f, 0.30f);
            pt.Assign(1, 1, 0.45f, 0.38f);
            pt.Assign(1, 2, 0.45f, 0.44f);
            pt.Assign(1, 3, 0.45f, 0.48f);

            pt.Assign(2, 0, 0.60f, 0.28f);
            pt.Assign(2, 1, 0.60f, 0.36f);
            pt.Assign(2, 2, 0.60f, 0.42f);
            pt.Assign(2, 3, 0.60f, 0.46f);

            pt.Assign(3, 0, 0.70f, 0.28f);
            pt.Assign(3, 1, 0.70f, 0.36f);
            pt.Assign(3, 2, 0.70f, 0.42f);
            pt.Assign(3, 3, 0.70f, 0.46f);

            pt.Assign(4, 0, 0.85f, 0.28f);
            pt.Assign(4, 1, 0.85f, 0.36f);
            pt.Assign(4, 2, 0.85f, 0.42f);
            pt.Assign(4, 3, 0.85f, 0.46f);

            pt.Assign(5, 0, 0.97f, 0.28f);
            pt.Assign(5, 1, 0.97f, 0.36f);
            pt.Assign(5, 2, 0.97f, 0.42f);
            pt.Assign(5, 3, 0.97f, 0.46f);

            return pt;
        }

        private PlayerTactics CreateRightForwardTactics()
        {
            PlayerTactics pt = new PlayerTactics(0.45f, 0.56f);

            pt.Assign(0, 0, 0.30f, 0.50f);
            pt.Assign(0, 1, 0.30f, 0.54f);
            pt.Assign(0, 2, 0.30f, 0.60f);
            pt.Assign(0, 3, 0.30f, 0.68f);

            pt.Assign(1, 0, 0.45f, 0.52f);
            pt.Assign(1, 1, 0.45f, 0.56f);
            pt.Assign(1, 2, 0.45f, 0.62f);
            pt.Assign(1, 3, 0.45f, 0.70f);

            pt.Assign(2, 0, 0.60f, 0.54f);
            pt.Assign(2, 1, 0.60f, 0.58f);
            pt.Assign(2, 2, 0.60f, 0.64f);
            pt.Assign(2, 3, 0.60f, 0.72f);

            pt.Assign(3, 0, 0.70f, 0.54f);
            pt.Assign(3, 1, 0.70f, 0.58f);
            pt.Assign(3, 2, 0.70f, 0.64f);
            pt.Assign(3, 3, 0.70f, 0.72f);

            pt.Assign(4, 0, 0.85f, 0.54f);
            pt.Assign(4, 1, 0.85f, 0.58f);
            pt.Assign(4, 2, 0.85f, 0.64f);
            pt.Assign(4, 3, 0.85f, 0.72f);

            pt.Assign(5, 0, 0.97f, 0.54f);
            pt.Assign(5, 1, 0.97f, 0.58f);
            pt.Assign(5, 2, 0.97f, 0.64f);
            pt.Assign(5, 3, 0.97f, 0.72f);

            return pt;
        }
    }
}
